math solution by Nand Kishore